package com.xwqiang.service.impl;

import com.xwqiang.pojo.model.SysUser;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;
import java.util.Collections;

@Getter
@Setter
public class AuthorSysUser extends User {

    //添加一个属性,将用户绑定到该属性上
    private SysUser sysUser;

    public AuthorSysUser(String username, String password, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, authorities);
    }

    /**
     * 有账号 有密码 无权限
     * @param sysUser
     */
    public AuthorSysUser(SysUser sysUser) {
        super(sysUser.getUsername(), sysUser.getPassword(), Collections.emptyList());
        this.sysUser = sysUser;
    }

    /**
     * 有账号 有密码 有权限
     * @param sysUser
     */
    public AuthorSysUser(SysUser sysUser, Collection<? extends GrantedAuthority> authorities) {
        super(sysUser.getUsername(), sysUser.getPassword(), authorities);
        this.sysUser = sysUser;
    }

}
